home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / MacHack Contest.sit / MacHack Contest / Test Code Folder / Problem 04 Test Code / Main.cp
MacBinary  |  1998-05-24  |  2.0 KB  |  [TEXT/CWIE]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert MS-DOS Code Page Info (other/dosCodePage) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sun May 24 17:12:19 1998, modified Sun May 24 17:12:19 1998, creator 'CWIE', type ASCII, 1376 bytes "Main.cp" , at 0x5e0 410 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CWIE]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 07 4d 61 69 6e 2e 63 | 70 00 00 00 00 00 00 00 |..Main.c|p.......|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 00 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 05 60 00 | 00 01 9a b1 8e 3d b3 b1 |......`.|.....=..|
|00000060| 8e 3d b3 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.=......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 fa 54 00 00 |........|.....T..|
|00000080| 23 69 6e 63 6c 75 64 65 | 20 22 53 6f 6c 75 74 69 |#include| "Soluti|
|00000090| 6f 6e 2e 68 22 0d 0d 23 | 69 6e 63 6c 75 64 65 20 |on.h"..#|include |
|000000a0| 22 50 72 6f 62 6c 65 6d | 55 74 69 6c 73 2e 68 22 |"Problem|Utils.h"|
|000000b0| 0d 0d 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 64 69 |..#inclu|de <stdi|
|000000c0| 6f 2e 68 3e 0d 23 69 6e | 63 6c 75 64 65 20 3c 73 |o.h>.#in|clude <s|
|000000d0| 74 72 69 6e 67 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |tring.h>|.#includ|
|000000e0| 65 20 3c 46 69 6c 65 73 | 2e 68 3e 0d 23 69 6e 63 |e <Files|.h>.#inc|
|000000f0| 6c 75 64 65 20 3c 45 72 | 72 6f 72 73 2e 68 3e 0d |lude <Er|rors.h>.|
|00000100| 0d 70 61 73 63 61 6c 20 | 4f 53 45 72 72 20 43 68 |.pascal |OSErr Ch|
|00000110| 65 63 6b 54 65 78 74 50 | 72 6f 63 65 73 73 28 20 |eckTextP|rocess( |
|00000120| 63 6f 6e 73 74 20 46 53 | 53 70 65 63 2a 20 69 6e |const FS|Spec* in|
|00000130| 66 69 6c 65 2c 20 63 6f | 6e 73 74 20 46 53 53 70 |file, co|nst FSSp|
|00000140| 65 63 2a 20 6f 75 74 66 | 69 6c 65 20 29 0d 7b 0d |ec* outf|ile ).{.|
|00000150| 09 4f 53 45 72 72 20 65 | 72 72 3b 0d 09 48 61 6e |.OSErr e|rr;..Han|
|00000160| 64 6c 65 20 64 61 74 61 | 20 3d 20 4e 55 4c 4c 3b |dle data| = NULL;|
|00000170| 0d 09 55 49 6e 74 33 32 | 20 61 63 74 69 6f 6e 5f |..UInt32| action_|
|00000180| 63 6f 75 6e 74 20 3d 20 | 30 3b 0d 09 41 63 74 69 |count = |0;..Acti|
|00000190| 6f 6e 52 65 63 6f 72 64 | 20 61 63 74 69 6f 6e 3b |onRecord| action;|
|000001a0| 0d 09 41 63 74 69 6f 6e | 52 65 63 6f 72 64 20 2a |..Action|Record *|
|000001b0| 2a 61 63 74 69 6f 6e 73 | 20 3d 20 4e 55 4c 4c 3b |*actions| = NULL;|
|000001c0| 0d 09 63 68 61 72 20 6c | 69 6e 65 5b 4d 41 58 5f |..char l|ine[MAX_|
|000001d0| 4c 49 4e 45 5f 4c 45 4e | 5d 3b 0d 09 63 68 61 72 |LINE_LEN|];..char|
|000001e0| 20 2a 70 3b 0d 09 0d 09 | 61 63 74 69 6f 6e 73 20 | *p;....|actions |
|000001f0| 3d 20 28 41 63 74 69 6f | 6e 52 65 63 6f 72 64 20 |= (Actio|nRecord |
|00000200| 2a 2a 29 20 4e 65 77 48 | 61 6e 64 6c 65 28 20 30 |**) NewH|andle( 0|
|00000210| 20 29 3b 0d 09 65 72 72 | 20 3d 20 4d 65 6d 45 72 | );..err| = MemEr|
|00000220| 72 6f 72 28 29 3b 0d 09 | 69 66 20 28 20 65 72 72 |ror();..|if ( err|
|00000230| 20 3d 3d 20 6e 6f 45 72 | 72 20 29 20 7b 0d 09 09 | == noEr|r ) {...|
|00000240| 65 72 72 20 3d 20 50 72 | 6f 62 6c 65 6d 46 69 6c |err = Pr|oblemFil|
|00000250| 65 52 65 61 64 28 20 69 | 6e 66 69 6c 65 2c 20 26 |eRead( i|nfile, &|
|00000260| 64 61 74 61 20 29 3b 0d | 09 7d 0d 09 69 66 20 28 |data );.|.}..if (|
|00000270| 20 65 72 72 20 3d 3d 20 | 6e 6f 45 72 72 20 29 20 | err == |noErr ) |
|00000280| 7b 0d 09 09 77 68 69 6c | 65 20 28 20 50 72 6f 62 |{...whil|e ( Prob|
|00000290| 6c 65 6d 52 65 61 64 4c | 69 6e 65 46 72 6f 6d 48 |lemReadL|ineFromH|
|000002a0| 61 6e 64 6c 65 28 20 64 | 61 74 61 2c 20 6c 69 6e |andle( d|ata, lin|
|000002b0| 65 2c 20 4d 41 58 5f 4c | 49 4e 45 5f 4c 45 4e 20 |e, MAX_L|INE_LEN |
|000002c0| 29 20 29 20 7b 0d 09 09 | 09 69 66 20 28 20 73 74 |) ) {...|.if ( st|
|000002d0| 72 63 6d 70 28 20 6c 69 | 6e 65 2c 20 22 45 4e 44 |rcmp( li|ne, "END|
|000002e0| 22 20 29 20 3d 3d 20 30 | 20 29 20 7b 0d 09 09 09 |" ) == 0| ) {....|
|000002f0| 09 62 72 65 61 6b 3b 0d | 09 09 09 7d 0d 09 09 09 |.break;.|...}....|
|00000300| 70 20 3d 20 6c 69 6e 65 | 3b 0d 09 09 09 69 66 20 |p = line|;....if |
|00000310| 28 20 50 72 6f 62 6c 65 | 6d 47 65 74 55 49 6e 74 |( Proble|mGetUInt|
|00000320| 33 32 28 20 26 70 2c 20 | 26 61 63 74 69 6f 6e 2e |32( &p, |&action.|
|00000330| 61 63 74 69 6f 6e 20 29 | 20 0d 09 09 09 09 09 26 |action )| ......&|
|00000340| 26 20 50 72 6f 62 6c 65 | 6d 47 65 74 53 49 6e 74 |& Proble|mGetSInt|
|00000350| 33 32 28 20 26 70 2c 20 | 26 61 63 74 69 6f 6e 2e |32( &p, |&action.|
|00000360| 61 6d 6f 75 6e 74 20 29 | 20 0d 09 09 09 09 09 26 |amount )| ......&|
|00000370| 26 20 50 72 6f 62 6c 65 | 6d 47 65 74 55 49 6e 74 |& Proble|mGetUInt|
|00000380| 33 32 28 20 26 70 2c 20 | 26 61 63 74 69 6f 6e 2e |32( &p, |&action.|
|00000390| 66 6c 61 67 73 20 29 20 | 29 20 7b 0d 09 09 09 09 |flags ) |) {.....|
|000003a0| 50 72 6f 62 6c 65 6d 47 | 65 74 53 74 72 69 6e 67 |ProblemG|etString|
|000003b0| 28 20 26 70 2c 20 61 63 | 74 69 6f 6e 2e 73 65 61 |( &p, ac|tion.sea|
|000003c0| 72 63 68 20 29 3b 0d 09 | 09 09 09 50 72 6f 62 6c |rch );..|...Probl|
|000003d0| 65 6d 47 65 74 53 74 72 | 69 6e 67 28 20 26 70 2c |emGetStr|ing( &p,|
|000003e0| 20 61 63 74 69 6f 6e 2e | 72 65 70 6c 61 63 65 20 | action.|replace |
|000003f0| 29 3b 0d 09 09 09 09 65 | 72 72 20 3d 20 50 74 72 |);.....e|rr = Ptr|
|00000400| 41 6e 64 48 61 6e 64 28 | 20 26 61 63 74 69 6f 6e |AndHand(| &action|
|00000410| 2c 20 28 48 61 6e 64 6c | 65 29 20 61 63 74 69 6f |, (Handl|e) actio|
|00000420| 6e 73 2c 20 73 69 7a 65 | 6f 66 28 41 63 74 69 6f |ns, size|of(Actio|
|00000430| 6e 52 65 63 6f 72 64 29 | 29 3b 0d 09 09 09 09 61 |nRecord)|);.....a|
|00000440| 63 74 69 6f 6e 5f 63 6f | 75 6e 74 2b 2b 3b 0d 09 |ction_co|unt++;..|
|00000450| 09 09 09 50 72 6f 62 6c | 65 6d 4c 6f 67 45 72 72 |...Probl|emLogErr|
|00000460| 6f 72 28 20 65 72 72 2c | 20 22 43 68 65 63 6b 54 |or( err,| "CheckT|
|00000470| 65 78 74 50 72 6f 63 65 | 73 73 3a 20 50 74 72 41 |extProce|ss: PtrA|
|00000480| 6e 64 48 61 6e 64 22 20 | 29 3b 0d 09 09 09 7d 20 |ndHand" |);....} |
|00000490| 65 6c 73 65 20 7b 0d 09 | 09 09 09 50 72 6f 62 6c |else {..|...Probl|
|000004a0| 65 6d 4c 6f 67 45 72 72 | 6f 72 28 20 2d 31 2c 20 |emLogErr|or( -1, |
|000004b0| 22 43 68 65 63 6b 54 65 | 78 74 50 72 6f 63 65 73 |"CheckTe|xtProces|
|000004c0| 73 3a 20 6e 6f 74 20 6e | 75 6d 62 65 72 73 22 20 |s: not n|umbers" |
|000004d0| 29 3b 0d 09 09 09 7d 0d | 09 09 7d 0d 09 09 48 4c |);....}.|..}...HL|
|000004e0| 6f 63 6b 28 20 28 48 61 | 6e 64 6c 65 29 20 61 63 |ock( (Ha|ndle) ac|
|000004f0| 74 69 6f 6e 73 20 29 3b | 0d 09 09 54 65 78 74 50 |tions );|...TextP|
|00000500| 72 6f 63 65 73 73 28 20 | 64 61 74 61 2c 20 61 63 |rocess( |data, ac|
|00000510| 74 69 6f 6e 5f 63 6f 75 | 6e 74 2c 20 2a 61 63 74 |tion_cou|nt, *act|
|00000520| 69 6f 6e 73 20 29 3b 0d | 09 09 65 72 72 20 3d 20 |ions );.|..err = |
|00000530| 50 72 6f 62 6c 65 6d 46 | 69 6c 65 57 72 69 74 65 |ProblemF|ileWrite|
|00000540| 28 20 6f 75 74 66 69 6c | 65 2c 20 64 61 74 61 20 |( outfil|e, data |
|00000550| 29 3b 0d 09 09 44 69 73 | 70 6f 73 65 48 61 6e 64 |);...Dis|poseHand|
|00000560| 6c 65 28 20 64 61 74 61 | 20 29 3b 0d 09 7d 0d 09 |le( data| );..}..|
|00000570| 72 65 74 75 72 6e 20 65 | 72 72 3b 0d 7d 0d 0d 69 |return e|rr;.}..i|
|00000580| 6e 74 20 6d 61 69 6e 28 | 29 0d 7b 0d 09 70 72 69 |nt main(|).{..pri|
|00000590| 6e 74 66 28 20 22 53 74 | 61 72 74 69 6e 67 5c 6e |ntf( "St|arting\n|
|000005a0| 22 20 29 3b 0d 09 0d 09 | 50 72 6f 62 6c 65 6d 52 |" );....|ProblemR|
|000005b0| 75 6e 46 69 6c 65 54 65 | 73 74 73 28 20 43 68 65 |unFileTe|sts( Che|
|000005c0| 63 6b 54 65 78 74 50 72 | 6f 63 65 73 73 20 29 3b |ckTextPr|ocess );|
|000005d0| 0d 0d 09 72 65 74 75 72 | 6e 20 30 3b 0d 7d 0d 0d |...retur|n 0;.}..|
|000005e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000600| 00 00 01 00 00 00 01 54 | 00 00 00 54 00 00 00 46 |.......T|...T...F|
|00000610| 2b 30 38 30 30 31 35 3a | 35 35 3a 33 32 20 31 39 |+080015:|55:32 19|
|00000620| 39 38 00 00 00 00 00 00 | 00 00 b1 78 6a 77 00 00 |98......|...xjw..|
|00000630| 07 4d 61 69 6e 2e 63 70 | 65 64 20 4d 61 63 48 61 |.Main.cp|ed MacHa|
|00000640| 63 6b 20 43 6f 6e 74 65 | 73 74 31 2e 73 69 74 69 |ck Conte|st1.siti|
|00000650| 02 4a 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |.JPartSI|T!......|
|00000660| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000670| 00 00 b1 b0 40 90 00 00 | 00 00 00 00 01 9a 00 00 |....@...|........|
|00000680| 00 00 29 bc 7f 92 00 00 | 00 00 20 52 65 3a 20 46 |..).....|.. Re: F|
|00000690| 6f 6c 64 65 72 20 48 69 | 65 72 61 72 63 68 79 20 |older Hi|erarchy |
|000006a0| 44 75 70 6c 69 63 61 74 | 69 6f 6e 0d 00 00 00 00 |Duplicat|ion.....|
|000006b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006c0| 00 00 00 00 00 00 00 00 | 00 04 36 35 37 a4 00 00 |........|..657...|
|000006d0| 00 00 00 00 00 00 00 00 | 00 01 be ab 00 00 05 f2 |........|........|
|000006e0| 00 00 02 90 02 07 31 32 | 2f 35 2f 39 38 34 30 30 |......12|/5/98400|
|000006f0| 30 32 31 3a 30 31 3a 35 | 36 20 31 39 39 38 00 00 |021:01:5|6 1998..|
|00000700| 00 00 00 48 00 0a 47 65 | 6e 65 76 61 00 00 00 00 |...H..Ge|neva....|
|00000710| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000720| 00 00 00 00 00 00 00 02 | 00 02 00 69 00 e8 02 6e |........|...i...n|
|00000730| 03 3e 00 69 00 e8 02 6e | 03 3e b1 8d f7 63 00 00 |.>.i...n|.>...c..|
|00000740| 01 bd 00 00 01 bd 00 00 | 00 00 01 00 00 00 00 04 |........|........|
|00000750| 00 01 00 01 00 00 01 00 | 00 00 01 54 00 00 00 54 |........|...T...T|
|00000760| 00 00 00 46 04 dc 54 d8 | 34 84 00 00 00 1c 00 46 |...F..T.|4......F|
|00000770| 00 01 4d 50 53 52 00 00 | 00 12 4d 57 42 42 00 00 |..MPSR..|..MWBB..|
|00000780| 00 1e 03 ed ff ff 00 00 | 00 00 00 00 00 00 03 f0 |........|........|
|00000790| ff ff 00 00 00 4c 00 00 | 00 00 00 00 00 00 00 00 |.....L..|........|
|000007a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+